﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace WebMsg
{
    public class TelAddress
    {
        // Constants
        const String mobNumVal = @"\d{10}";

        public String Number { get; private set; }
        public String Name { get; private set; }

        public TelAddress(String name, String number)
        {
            if (String.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name");

            if (name.Length > Sms.LEN_SENDER)
                throw new ArgumentException("Name too long. Max length of " + Sms.LEN_SENDER);

            if (!Regex.IsMatch(number, mobNumVal))
                throw new ArgumentException("Invalid mobile number.");            

            this.Name = name;
            this.Number = number;
        }
    }
}
